package in.muton.edushare.pages.publicpages.userpages;

import org.apache.wicket.PageParameters;
import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.edushare.common.constants.RequestConstants;
import com.edushare.common.vo.Users;

public class ProfileTopMenu extends Panel {

	public static enum MenuItems{
		SUMMARY,
		EXPERIENCE,
		EDUCATION,
		PUBLICATIONS
	};
	
	public ProfileTopMenu(String id, IModel<Users> userModel,MenuItems selectedTab) {
		super(id);
		add(CSSPackageResource.getHeaderContribution(ProfileTopMenu.class, "ProfileTopMenu.css"));
		PageParameters sumParam = new PageParameters();
		sumParam.add("0", userModel.getObject().getUserName());
		WebMarkupContainer sumdiv = new WebMarkupContainer("sumDiv");
		BookmarkablePageLink<Void> sumLink 
			= new BookmarkablePageLink<Void>("sumLink", UserProfile.class, sumParam);
		WebMarkupContainer sumwmc = new WebMarkupContainer("sum");
		sumdiv.add(sumLink);
		sumdiv.add(sumwmc);
		add(sumdiv);
		if(selectedTab==MenuItems.SUMMARY){
			sumLink.setVisible(false);
			sumdiv.add(new SimpleAttributeModifier("class", "sel"));
		}
		else
			sumwmc.setVisible(false);
		
		
		PageParameters expParam = new PageParameters();
		expParam.add("0", userModel.getObject().getUserName());
		expParam.add("1",RequestConstants.PARAM_USR_EXPERIENCES);
		WebMarkupContainer expDiv = new WebMarkupContainer("expDiv");
		BookmarkablePageLink<Void> expLink 
			= new BookmarkablePageLink<Void>("expLink", ProfessionalProfile.class, expParam);
		WebMarkupContainer expwmc = new WebMarkupContainer("exp");
		add(expDiv);
		expDiv.add(expLink);
		expDiv.add(expwmc);
		if(selectedTab==MenuItems.EXPERIENCE){
			expLink.setVisible(false);
			expDiv.add(new SimpleAttributeModifier("class", "sel"));
		}else{
			expwmc.setVisible(false);
		}
		
		PageParameters eduParam = new PageParameters();
		eduParam.add("0", userModel.getObject().getUserName());
		eduParam.add("1",RequestConstants.PARAM_USR_EDUCATION);
		WebMarkupContainer eduDiv = new WebMarkupContainer("eduDiv");
		BookmarkablePageLink<Void> eduLink 
			= new BookmarkablePageLink<Void>("eduLink", ProfessionalProfile.class, eduParam);
		WebMarkupContainer eduwmc = new WebMarkupContainer("edu");
		add(eduDiv);
		eduDiv.add(eduLink);
		eduDiv.add(eduwmc);
		if(selectedTab==MenuItems.EDUCATION){
			eduLink.setVisible(false);
			eduDiv.add(new SimpleAttributeModifier("class", "sel"));
		}else{
			eduwmc.setVisible(false);
		}
		
		PageParameters pubParam = new PageParameters();
		pubParam.add("0", userModel.getObject().getUserName());
//		pubParam.add("1",RequestConstants.PARAM_USR_PUBLICATIONS);
		WebMarkupContainer pubDiv = new WebMarkupContainer("pubDiv");
		BookmarkablePageLink<Void> pubLink 
			= new BookmarkablePageLink<Void>("pubLink", UserPublications.class, pubParam);
		WebMarkupContainer pubwmc = new WebMarkupContainer("pub");
		add(pubDiv);
		pubDiv.add(pubLink);
		pubDiv.add(pubwmc);
		if(selectedTab==MenuItems.PUBLICATIONS){
			pubLink.setVisible(false);
			pubDiv.add(new SimpleAttributeModifier("class", "sel"));
		}else{
			pubwmc.setVisible(false);
		}
	}		

}
